/*
 * Copyright 2012 Faculty of Informatics - Masaryk University.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cz.muni.fi.pa165.creatures.model.web;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * Primary key in {@link cz.muni.fi.pa165.creatures.model.web.PersonFunction}.
 *
 * @author smikloso
 */
@Embeddable
public class PersonFunctionPK implements Serializable {

    private static final long serialVersionUID = -4094084150903012986L;

    @Column(name = "person_id")
    private Long personId;

    @Column(name = "function_id")
    private Long functionId;

    public PersonFunctionPK() {
    }

    public PersonFunctionPK(Long personId, Long functionId) {
        this.personId = personId;
        this.functionId = functionId;
    }

    public Long getPersonId() {
        return personId;
    }

    public void setPersonId(Long personId) {
        this.personId = personId;
    }

    public Long getFunctionId() {
        return functionId;
    }

    public void setFunctionId(Long functionId) {
        this.functionId = functionId;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.personId != null ? this.personId.hashCode() : 0);
        hash = 59 * hash + (this.functionId != null ? this.functionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof PersonFunctionPK)) {
            return false;
        }
        PersonFunctionPK other = (PersonFunctionPK) obj;

        if (this.personId != other.personId) {
            return false;
        }
        if (this.functionId != other.functionId) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "PersonFunctionPK{" + "personId=" + personId + ", functionId=" + functionId + '}';
    }
}
